<ui:composition template="/pages/templates/layout.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="title">Enregistrement des journalistes</ui:define>
	<ui:define name="content">
		<h:form id="form">
			<p:messages id="messages" showDetail="true" autoUpdate="true"
				closable="true" />

			<p:panel id="toggleable" header="ENREGISTREMENT DES JOURNALISTES"
				toggleable="true" toggleSpeed="500" widgetVar="panel">
				<p:fieldset id="saisie" legend="Saisie des informations"
					toggleable="true" toggleSpeed="500">
					<h:panelGrid columns="3" cellpadding="10">
						<p:outputLabel for="nom" value="Nom et Prénom" />
						<p:inputText id="nom" styleClass="field-uppercase"
							value="#{journalisteBean.currentJournaliste.journalisteNom}"
							required="true">
						</p:inputText>
						<p:message id="nomMsg" for="nom" display="icon" />

						<p:outputLabel for="dateNaiss" value="Date de naissance" />
						<p:calendar id="dateNaiss"
							value="#{journalisteBean.currentJournaliste.journalisteDateNaiss}"
							locale="fr" navigator="true" showButtonPanel="true"
							required="true" pattern="dd/MM/yyyy" maxdate="31/12/1996">
							<p:ajax update="dateNaissMsg" event="keyup" />
						</p:calendar>
						<p:message id="dateNaissMsg" for="dateNaiss" display="icon" />
					</h:panelGrid>

					<p:separator />

					<p:commandButton value="Enrégistrer"
						binding="#{journalisteBean.btnSave}"
						action="#{journalisteBean.saveJournaliste}" icon="ui-icon-disk"
						update="@all" disabled="false">
						<p:confirm header="Confirmation"
							message="Voulez-vous enrégistrer ?" icon="ui-icon-alert" />
					</p:commandButton>
					<p:commandButton value="Modifier"
						binding="#{journalisteBean.btnUpdate}"
						action="#{journalisteBean.updateJournaliste}"
						icon="ui-icon-refresh" update="@all" disabled="true">
						<p:confirm header="Confirmation" message="Voulez-vous modifier ?"
							icon="ui-icon-alert" />
					</p:commandButton>
					<p:commandButton value="Supprimer"
						binding="#{journalisteBean.btnDelete}"
						action="#{journalisteBean.deleteJournaliste}" icon="ui-icon-trash"
						update="@all" disabled="true">
						<p:confirm header="Confirmation" message="Voulez-vous supprimer ?"
							icon="ui-icon-alert" />
					</p:commandButton>
					<p:commandButton value="Imprimer" disabled="true"
						icon="ui-icon-trash" update="@all" styleClass="btImp"
						binding="#{journalisteBean.btnImp}"
						action="#{journalisteBean.imprimerJournaliste}">
						<p:confirm header="Confirmation" message="Voulez-vous imprimer ?"
							icon="ui-icon-alert" />
					</p:commandButton>

					<p:commandButton value="Imprim" process="@this" ajax="false"
						icon="ui-icon-trash" actionListener="#{journalisteBean.imprimNav}">
					</p:commandButton>
					<p:commandButton value="PRINT"
						actionListener="#{journalisteBean.imprimNav}"></p:commandButton>

					<p:commandButton value="Imprimer tout" icon="ui-icon-trash"
						update="@all" styleClass="btnImpTout"
						action="#{journalisteBean.imprimerAllJournaliste}">
						<p:confirm header="Confirmation" message="Voulez-vous imprimer ?"
							icon="ui-icon-alert" />
					</p:commandButton>

					<p:commandButton value="Annuler"
						action="#{journalisteBean.resetField}" icon="ui-icon-cancel"
						update=":form:saisie" />

					<p:confirmDialog global="true" showEffect="puff"
						hideEffect="explode">
						<p:commandButton value="Oui" type="button"
							styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
						<p:commandButton value="Non" type="button"
							styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
					</p:confirmDialog>
				</p:fieldset>

				<p:dataTable id="table" var="journaliste"
					value="#{journalisteBean.journalistes}"
					selection="#{journalisteBean.selectedJournaliste}"
					selectionMode="single" rowKey="#{journaliste.journalisteId}"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					paginator="true" rows="10" rowsPerPageTemplate="5,10,15"
					styleClass="table">
					<p:ajax event="rowSelect" listener="#{journalisteBean.updateField}"
						update=":form:saisie" />
					<p:column headerText="Identifiants" styleClass="column">
						<h:outputText value="#{journaliste.journalisteId}" />
					</p:column>

					<p:column headerText="Noms" styleClass="column">
						<h:outputText value="#{journaliste.journalisteNom}" />
					</p:column>

					<p:column headerText="Dates de naissances" styleClass="column">
						<h:outputText value="#{journaliste.journalisteDateNaiss}">
							<f:convertDateTime pattern="dd-MM-yyyy" />
						</h:outputText>
					</p:column>
				</p:dataTable>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>
